<?xml version="1.0" encoding="UTF-8"?>
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" 
"http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">

<ui:composition template="../template/template.xhtml"
    xmlns="http://www.w3.org/1999/xhtml"
	xmlns:h="http://java.sun.com/jsf/html"
	xmlns:f="http://java.sun.com/jsf/core"
	xmlns:ui="http://java.sun.com/jsf/facelets"
	xmlns:p="http://primefaces.org/ui"
	xmlns:c="http://java.sun.com/jsp/jstl/core">
	

<body>
	
	<!--Lista de Estabelecimentos Cadastrados -->
	
		<ui:define name="content">
			<h:form id="formListaEstabelecimentos">
			
			 <p:growl id="messages" showDetail="true"/>  
			
		      <p:dataTable style="width:1313px; " id="dataTable"  var="est" value="#{estabelecimentoMB.listaEstabelecimentos}" 
		        editable="true" editMode="cell" widgetVar="estTable"   
           		emptyMessage="Não há clientes cadastrados."
           		paginator="true" rows="15" >   
           		 
           		<p:ajax event="cellEdit" listener="#{estabelecimentoMB.alterarEstabelecimento}" update=":formListaEstabelecimentos:messages"/>  
           		
  				<h:inputHidden id="hiddenId" value="#{est.id}" />
  				<h:inputHidden id="hiddenAtivo" value="#{est.isAtivo}" />
  				
				<p:column id="nome" headerText="Nome" styleClass="text_table" >  
				     <p:cellEditor>  
				    	<f:facet name="output"><h:outputText value="#{est.nome}" /></f:facet>	
						<f:facet name="input"><h:inputText value="#{est.nome}" style="width:96%" disabled="#{est.isAtivo == true ? 'true' : 'false'}"/></f:facet>		        
			         </p:cellEditor>  
		        </p:column>  
		        
		        <p:column  id="cnpj" headerText="CNPJ" styleClass="text_table" >  
				     <p:cellEditor>  
				    	<f:facet name="output"><h:outputText value="#{est.cnpj}" /></f:facet>	
						<f:facet name="input"><p:inputMask value="#{est.cnpj}" size="15" mask="99.999.999/9999-99" disabled="#{est.isAtivo == true ? 'true' : 'false'}" /></f:facet>
			         </p:cellEditor>  
		        </p:column> 
		        
		         <p:column headerText="Data" styleClass="text_table" >  
				     <h:outputText value="#{est.data}" />	
		        </p:column> 
		     	        
		        <p:column styleClass="text_table" headerText="Endereço" style="width:2%;">
		          <p:commandLink update=":formListaEstabelecimentos:endForm:modalEndereco" oncomplete="modalEndereco.show()" disabled="#{est.isAtivo == true ? 'true' : 'false'}">  
		          	<p:graphicImage value="../resources/imagens/home.png" width="20" height="20"></p:graphicImage>
		          	<f:setPropertyActionListener target="#{estabelecimentoMB.mostrarEstabelecimento}" value="#{est}"></f:setPropertyActionListener>
		          </p:commandLink>  
		        </p:column>
		        
		           
		         <p:column  id="comercial" headerText="Tel. Comercial" styleClass="text_table" >  
				     <p:cellEditor>  
				    	<f:facet name="output"><h:outputText value="#{est.comercial}" /></f:facet>	
						<f:facet name="input"><h:inputText value="#{est.comercial}" style="width:50%" disabled="#{est.isAtivo == true ? 'true' : 'false'}" /></f:facet>		        
			         </p:cellEditor>  
		        </p:column> 
		        
		        <p:column id="contato" headerText="Contato" styleClass="text_table" >  
				     <p:cellEditor>
				     	<f:facet name="output"><h:outputText value="#{est.contato}" /></f:facet>	
						<f:facet name="input"><h:inputText value="#{est.contato}" style="width:50%" disabled="#{est.isAtivo == true ? 'true' : 'false'}" /></f:facet>		        
			         </p:cellEditor>  
		        </p:column> 
		        
		        <p:column id="email"  headerText="Email" styleClass="text_table" >  
				     <p:cellEditor>  
				    	<f:facet name="output"><h:outputText value="#{est.email}" /></f:facet>	
						<f:facet name="input"><h:inputText value="#{est.email}" style="width:96%" disabled="#{est.isAtivo == true ? 'true' : 'false'}" /></f:facet>		        
			         </p:cellEditor>  
		        </p:column>
		     	      
		        <p:column id="desativado" headerText="Desativar" style="width: 2%;">
		          
		           <p:commandButton id="desativarEst" actionListener="#{estabelecimentoMB.desativarEstabelecimento}" oncomplete="modalObs.show();"
		                 icon="#{est.isAtivo == true? 'ui-icon-check' : 'ui-icon-close'}" update="desativarEst dataTable" 
		                  style="height:15px; margin-left: 15px;">
		           		<f:setPropertyActionListener target="#{estabelecimentoMB.mostrarEstabelecimento}" value="#{est}"></f:setPropertyActionListener>
		           </p:commandButton>
        
		              <p:commandLink id="linkMsg" action="#{estabelecimentoMB.carregaMsgObs}" oncomplete="msgObs.show()" update=":formListaEstabelecimentos:formMsg:msgObs">  
			          		<p:graphicImage value="../resources/imagens/icone_message.png" rendered="#{est.obsInativo != ''}" width="20" height="20"></p:graphicImage>
		            		<f:setPropertyActionListener target="#{estabelecimentoMB.mostrarEstabelecimento}" value="#{est}"></f:setPropertyActionListener>
		              </p:commandLink>  
     	          
		            <p:tooltip for="desativarEst" value="#{est.isAtivo == true? 'Ativar Estabelecimento' : ' Desativar Estabelecimento'}" showEffect="fade" hideEffect="fade" />  
		        </p:column>
  			</p:dataTable>  
    			
    			<ui:include src="../cadastro/endereco/mostrarEndereco.xhtml"></ui:include>
    			<ui:include src="../cadastro/mostrarEstabelecimento.xhtml"></ui:include>
    			<ui:include src="../cadastro/mostrarCliente.xhtml"></ui:include>
    			<ui:include src="../cadastro/alterarCliente.xhtml"></ui:include>
    			<ui:include src="../cadastro/mensagemObservação.xhtml"></ui:include>
    			
    	</h:form>
    	
    	<ui:include src="../cadastro/modalObservacao.xhtml"></ui:include>

</ui:define>

</body>
</ui:composition>
